{
	const PARAMETER = {
		MAX_DUIRATION : 0.7,
		MAX_MOVE_VAL : 100
	}

	const STYLE = {
		LOADINGBOX : {
			position : "fixed",
			left : "0px;",
			top : "0px",
			height : "45px",
			width : "100%",
			backgroundColor : "transparent", 
			justifyContent : "center",
			alignItems: "center",
			zIndex : "998",
			display : "none"
		}
	}

	const IMG = {
		DOWN_ARROW : ''
		
	}

	class Crefresh {
		constructor (option = {}) {
			let target = document.querySelector(option.selector);
			let mouseDistance = 0;

			this.target = {
				dom : target,
				height : target.offsetHeight 
			}

			let loadingBox = document.createElement('div');
			for(let key in STYLE.LOADINGBOX ) {
				loadingBox.style[key] = STYLE.LOADINGBOX[key];
			}
			window.document.body.appendChild(loadingBox); 
			 
			this.target.dom.addEventListener('touchstart',(event) => { 
				mouseDistance = event.touches[0].clientY - this.target.dom.offsetTop; 
				this.target.dom.style.position = "fixed"; 
				this.target.dom.style.zIndex = "999"; 
				this.target.dom.style.top = '1px';
				loadingBox.style.display = "flex";
			},false);

			loadingBox.innerHTML = option.loadingHtml ;

			this.target.dom.addEventListener('touchmove', (event) => { 
				this.target.dom.style.top = (event.touches[0].clientY - mouseDistance) - ( this.target.dom.offsetTop * 0.9)  + "px"; 
			},false);

			this.target.dom.addEventListener('touchend', () => {

				this.target.dom.style.transition = "all "+ PARAMETER.MAX_DUIRATION +"s ease-out";
				this.target.dom.style.top = "45px";

				setTimeout(() => {
					this.target.dom.style.transition = "all "+ PARAMETER.MAX_DUIRATION / 2 +"s ease-out";
					this.target.dom.style.top = "0px";
					setTimeout(() => {
						this.target.dom.style.transition = "";
						this.target.dom.style.top = "";  
						this.target.dom.style.position = "static"; 
						loadingBox.style.display = "none"; 
						mouseDistance = 0;
						option.done();
					},(PARAMETER.MAX_DUIRATION / 2) * 1000);
				},1000); 
			},false);

		}

	}

	if ( !window.Crefresh ) window.Crefresh = Crefresh;
}